<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box{
      width:100px;
      height: 100px;
      background-color: rgb(224, 203, 11);
      margin: 50px auto;
    }
    .box2{
      width:100px;
      height: 100px;
      background-color: rgb(118, 204, 38);
      margin: 50px auto;
    }
    .ani1-enter{
      transform: translateX(-500px) rotate(360deg);
      opacity: 0;
    }
    .ani1-enter-active,.ani1-leave-active{
      transition: all 400ms;
    }
    .ani1-leave-to{
      transform: translateY(500px) rotate(-360deg);
      opacity: 0;
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="change">
      {{ isShow?'消失':'显示' }}
    </button>
    <transition name="ani1" mode="out-in">
      <div key="1" v-if="isShow" class="box"></div>
      <div key="2" v-else class="box2"></div>
    </transition>
    <script src="./vue.js"></script>
    <script>
      const vm = new Vue({
        el:'#app',
        data:{
          isShow: false
        },
        methods: {
          change(){
            this.isShow = !this.isShow;
          }
        }
      })
    </script>
  </div>
</body>
</html>